Skip to content

Add TypeScript interpreter detection module#3703

Merged
zackverham merged 1 commit intomainfrom
interpreters-module
Mar 12, 2026
Merged

Add TypeScript interpreter detection module#3703
zackverham merged 1 commit intomainfrom
interpreters-module

Conversation

@zackverham
Copy link
Collaborator

Summary

  • Adds a self-contained TypeScript module (src/interpreters/) for detecting Python and R interpreters
  • Includes version constraint parsing, interpreter detection via subprocess probing, and shared filesystem utilities
  • Adds requiresPython / requiresR fields to PythonConfig / RConfig types and fill-in logic in UpdateConfigWithDefaults
  • All source files use only Node.js builtins (no vscode dependency), making the module testable in isolation

This is PR 1 of 3 splitting up #3672. The module is entirely new code with no behavior change — it has no consumers yet.

PR chain: PR 1 (this) → PR 2 (wire into state.ts) → PR 3 (integration tests + CI)

Test plan

  • npx tsc --noEmit passes
  • npx vitest run src/interpreters/ — 81 tests pass
  • npx prettier --check passes
  • CI passes

🤖 Generated with Claude Code

Copy link
Collaborator

@christierney christierney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the version constraint function only get applied to the version strings from certain files, not all (e.g. .python-version but not pyproject.toml). Is that intentional?

}
if (!config.configuration.r.requiresR) {
config.configuration.r.requiresR = defaults.r.requiresR;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should have been included when I added these fields to the configuration types. This is technically a behavior change, right? Even though the rest of this PR is not wired up to anything yet?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I suppose it is - this change is weird because of of how the config got filled in on the go side vs how we're doing it now on the typescript side.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to keep this PR self-contained and scoped to just implementation + tests without behavior changes, I could pull this out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that actually is nice - because it also forces the types for interpreters to be self-contained in this module as well - before we were relying on the old api types, which feels weird.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow 😄 but I'm good with whatever, just wanted to mention it

Add a self-contained TypeScript module for detecting Python and R
interpreters, replacing the Go backend's /api/interpreters endpoint.

The module includes:
- Version constraint parsing (requires-python/requires-r from metadata)
- Python interpreter detection via sys.executable and version probing
- R interpreter detection via R --version parsing
- Shared filesystem utilities for reading files and checking existence

All source files use only Node.js builtins (no vscode dependency),
making the module testable in isolation with vitest. The module defines
its own local types (PythonInterpreterConfig, RInterpreterConfig,
InterpreterDetectionResult) so no existing files are modified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zackverham zackverham force-pushed the interpreters-module branch from 9103644 to 60901e6 Compare March 12, 2026 14:26
Copy link
Collaborator

@dotNomad dotNomad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome!

@zackverham
Copy link
Collaborator Author

zackverham commented Mar 12, 2026

It seems like the version constraint function only get applied to the version strings from certain files, not all (e.g. .python-version but not pyproject.toml). Is that intentional?

I looked into this - it looks like .python-version in particular can just specify the version, not a PEP 440 version constraint, which is why there's extra handling there.

https://packaging.python.org/en/latest/specifications/pyproject-toml/#requires-python
https://packaging.python.org/en/latest/specifications/version-specifiers/
https://setuptools.pypa.io/en/latest/references/keywords.html

@zackverham zackverham merged commit 4a05ed4 into main Mar 12, 2026
27 checks passed
@zackverham zackverham deleted the interpreters-module branch March 12, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants